<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="25" :xs="24"> 公司部门 <el-select v-model="s_search.CMID7">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in l_firm" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 人员 <el-select v-model="s_search.CMID8">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 范围类别 <el-select v-model="s_search.CMIDcode">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_type" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 工序分类 <el-select v-model="s_search.CMIDprocess_classid">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in l_class" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <div class="el-select">
            <el-input v-model="s_search.process_name" placeholder='工序名称' />
          </div>
          <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
          <el-button @click="gotoPage('/mes/product/ProcedureAdd?'+vueparams+'')" type='primary' size="mini">添加工序</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 检测工序 </span>
          </div>
          <div>
          </div>
          <el-table :data="pageList" v-loading="loading">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_process('&CMID='+scope.row.process_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/mes/product/ProductProDetUp?CMID='+scope.row.process_id+''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/mes/product/ProductProDet?CMID='+scope.row.process_id+''+vueparams+'')">查看明细</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/mes/product/CartogramProcedure?'+vueparams+'')">核对所有工序</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/mes/product/CartogramProcedure?'+vueparams+'')">清除所有项目</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="工序分类" prop="pro_produce_name">
            </el-table-column>
            <el-table-column label="工序条形码" prop="process_barcode">
            </el-table-column>
            <el-table-column label="工序名称" prop="process_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/mes/product/ProductProDet?CMID='+scope.row.process_id+''+vueparams+'')" type='primary'>{{scope.row.process_name}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="工序性质" prop="process_nature">
            </el-table-column>
            <el-table-column label="标准文件编号" prop="subject">
            </el-table-column>
            <el-table-column label="变更状态" prop="process_state">
            </el-table-column>
            <el-table-column label="工序描述" prop="process_des">
            </el-table-column>
            <el-table-column label="工序管理岗位" prop="role">
            </el-table-column>
            <el-table-column label="每时能力值" prop="throughput">
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'CartogramProcedure',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams("&CMODULEID=pro_produce&CMID5=14"),
        s_search: {
          CMID7: null,
          CMID8: null,
          CMIDcode: null,
          CMIDprocess_classid: null,
          process_name: null,
        },
        p_pro: [],
        l_firm: [],
        s_person: [],
        s_type: [],
        l_class: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/cartogramProcedure?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_process(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/d_process?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getPage(page) {
        this.loading = true;
        this.s_search.pageNo = page.page || page;
        this.s_search.pageSize = page.limit || 10;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/s_pro?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
    },
  }
</script>
